package com.example.myapplication

import com.example.myapplication.clean_craftsmanship.MyWrap
import org.junit.Test

/**
 *Create by Fanketly on 2022/9/2
 *Gitee:https://gitee.com/fanketly
 *desc:
 */
class WrapTest {
    private val myWrap = MyWrap()

    @Test
    fun createWrap() {
        val myWrap = MyWrap()
    }

    val string =
        "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions" +
                "Calculate the absolute offset for the current page from the scroll position. We use the absolute value which allows us to mirror any effects for both directions"

    @Test
    fun input() {
        myWrap.wrap(string)
    }

    @Test
    fun output() {
        println(string)
    }

    @Test
    fun wrapEveryWord() {
        println(myWrap.wrap(string))
    }

    @Test
    fun wrap300Width() {
        val currentTimeMillis = System.currentTimeMillis()
        println("12345678101234567820")
//        println(myWrap.wrap(string, 300))
        //5次测试时间：3 3 3 4 3
//    长字符串    12 11 12 12 13
        println(myWrap.wrap3(string, 300))
        //4 4 3 3 3
//  长字符串      11 12 11 12 11
        val currentTimeMillis1 = System.currentTimeMillis()
        println(currentTimeMillis1 - currentTimeMillis)
    }

    @Test
    fun wrap20Width() {
        //此处就是遇到卡壳，原先是3，现改为更容易测试的20，遵守了规则8
        val currentTimeMillis = System.currentTimeMillis()
        println("12345678101234567820")
        println(myWrap.wrap(string, 20))
        //5次测试时间：11 10 11 11 12
        // 15 14
//        println(myWrap.wrap3(string, 20))
        //10 10  11 10 11
        //15 14
        val currentTimeMillis1 = System.currentTimeMillis()
        println(currentTimeMillis1 - currentTimeMillis)
    }

    @Test
    fun wrap5Width() {
        val currentTimeMillis = System.currentTimeMillis()
        println("12345678101234567820")
        println(myWrap.wrap(string, 5))
        //5次测试时间：12 11 11 11 11
//        println(myWrap.wrap3(string, 5))
        //11 11  11 12 12
        val currentTimeMillis1 = System.currentTimeMillis()
        println(currentTimeMillis1 - currentTimeMillis)
    }

    @Test
    fun wrapWidth() {
        val currentTimeMillis = System.currentTimeMillis()
        println("12345678101234567820")
        println(myWrap.wrap(string, 1))
        //5次测试时间：13 13 12 14 13
        //25 24 26 24
//        println(myWrap.wrap3(string, 1))
//        15 13  13 13 14
        //54 40 50 52
        val currentTimeMillis1 = System.currentTimeMillis()
        println(currentTimeMillis1 - currentTimeMillis)
    }

}